#include <iostream> 
#include <fstream> 
#include <cmath> 
#include <algorithm> 
#include <cassert> 
#include <string> 
#include <cstdlib> 
#include <cstdio> 
#include <vector> 
#include <map> 
#include <set> 

#define itn int 
#define float long double 
#define LL long long
#define x first
#define y second
#define pb push_back
#define mp make_pair

using namespace std;

string solve(const string & s, const string & t, int l, int r, int l1, int r1, int D){
//	cout << l << r << l1 << r1 << D << "\n";
	if (D == 0){
		string res = "";
		for (int i = l; i < r; i++) res += '\\';
		return res;
	}
	if (r == l){
		string res = "";
		for (int i = l1; i < r1; i++) res += '-';
		return res;
	}
	if (r1 == l1){
		string res = "";
		for (int i = l; i < r; i++) res += '|';
		return res;
	}
	if (D == 1){
		int x = l, y = l1;
		string res = "";
		while (x < r && y < r1 && s[x] == t[y]){
			res += '\\';
			x++;
			y++;
		}
		if (r - l < r1 - l1){
			res += '-';
			y++;
		} else {
			res += '|';
			x++;
		}
		while (x < r){
			res += '\\';
			x++;
		}
		return res;
	}
	vector<pair<int, int> > a((D + 3) / 2), b((D + 3) / 2), c((D + 3) / 2);
	for (int d = 0; d <= (D + 1) / 2; d++){
		for (int i = 0; i <= d; i++){
			if (d == 0){
				int x = l, y = l1;
				while (x < r && y < r1 && s[x] == t[y]){
					x++;
					y++;
				}
				a[i] = mp(x, y);
			} else {
				a[i] = mp(0, 0);
				pair<int, int> p;
				if (i < d){
					p = b[i];
					p.x++;
					while (p.x < r && p.y < r1 && s[p.x] == t[p.y]) {p.x++; p.y++;}
					if (a[i].x < p.x || a[i].y < p.y) a[i] = p;
				}
				if (i > 0){
					p = b[i - 1];
					p.y++;
					while (p.x < r && p.y < r1 && s[p.x] == t[p.y]) {p.x++; p.y++;}
					if (a[i].x < p.x || a[i].y < p.y) a[i] = p;
				}
			}
		}
		swap(a, b);
	}
	swap(a, b);
	for (int d = 0; d <= D / 2; d++){
		for (int i = 0; i <= d; i++){
			if (d == 0){
				int x = r, y = r1;
				while (x > l && y > l1 && s[x - 1] == t[y - 1]) {x--, y--;}
				c[i] = mp(x, y);
			} else {
				c[i] = mp(r, r1);
				pair<int, int> p;
				if (i < d){
					p = b[i];
					p.y--;
					while (p.x > l && p.y > l1 && s[p.x - 1] == t[p.y - 1]) {p.x--; p.y--;}
					if (c[i].x > p.x || c[i].y > p.y) c[i] = p;
				}
				if (i > 0){
					p = b[i - 1];
					p.x--;
					while (p.x > l && p.y > l1 && s[p.x - 1] == t[p.y - 1]) {p.x--; p.y--;}
					if (c[i].x > p.x || c[i].y > p.y) c[i] = p;
				}
			}
		}
		swap(c, b);
	}
	swap(c, b);
	int mm = 0;
	for (int i = 0; i <= (D + 1) / 2; i++){
		if (2 * i + (r - l) - (r1 - l1) - D % 2 >= 0 && 2 * i + (r - l) - (r1 - l1) - D % 2 <= D + (D + 1) % 2 && a[i].x >= c[(2 * i + (r - l) - (r1 - l1) - D % 2) / 2].x) mm = i;
	}
//	cout << mm << a[mm].x << a[mm].y << "\n";
	return solve(s, t, l, a[mm].x, l1, a[mm].y, (D + 1) / 2) + solve(s, t, a[mm].x, r, a[mm].y, r1, D / 2);
}

int main(){ 
	
	string s, t;
	cin >> s >> t;
	int n = s.length(), m = t.length();
	vector<pair<int, int> > a(m + n + 1), b(m + n + 1);
	int ans = -1;
	for (int d = 0; d <= m + n && ans < 0; d++){
		for (int i = 0; i <= d && ans < 0; i++){
			if (d == 0){
				int x = 0, y = 0;
				while (x < n && y < m && s[x] == t[y]) x = ++y;
				a[i] = mp(x, y);
			} else {
				a[i] = mp(0, 0);
				pair<int, int> p;
				if (i < d){
					p = b[i];
					p.y++;
					while (p.x < n && p.y < m && s[p.x] == t[p.y]) {p.x++; p.y++;}
					if (a[i].x < p.x || a[i].y < p.y) a[i] = p;
				}
				if (i > 0){
					p = b[i - 1];
					p.x++;
					while (p.x < n && p.y < m && s[p.x] == t[p.y]) {p.x++; p.y++;}
					if (a[i].x < p.x || a[i].y < p.y) a[i] = p;
				}
			}
			if (a[i].x == n && a[i].y == m){
				ans = d;
				break;
			}
		}
		swap(a, b);
	}
	cout << ans << "\n";
//	cout << solve(s, t, 0, n, 0, m, ans);
	string res = solve(s, t, 0, n, 0, m, ans);
//	cout << res << "\n";
	int i = 0, j = 0;
	for (int _ = 0; _ < res.length(); _++){
		if (res[_] == '-') cout << "-"; else cout << s[i++];
	}
	cout << "\n";
	for (int _ = 0; _ < res.length(); _++){
		if (res[_] != '\\') cout << " "; else cout << '|';
	}
	cout << "\n";
	for (int _ = 0; _ < res.length(); _++){
		if (res[_] == '|') cout << "-"; else cout << t[j++];
	}
	cout << "\n";
	
	return 0; 
} 
